import { create } from "zustand"
import { immer } from "zustand/middleware/immer"
import { devtools } from "zustand/middleware"

type UserState = {
  currentUser: UserResponse | null
  setCurrentUser: (newCurrentUser: UserResponse | null) => void
}

const useUserStore = create<UserState>()(
  devtools(
    immer((set) => ({
      currentUser: null,
      setCurrentUser: (newCurrentUser: UserResponse | null) => {
        set((state) => {
          state.currentUser = newCurrentUser
        })
      }
    }))
  )
)

export default useUserStore
